package com.xj.api.bussiness.type.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.xj.api.base.web.BaseController;
import com.xj.api.bussiness.type.service.impl.ITbTypeService;
import com.xj.common.base.common.bean.AbstractBean;
import com.xj.common.bussiness.news.entity.TbType;

import io.swagger.annotations.ApiOperation;


@RestController
@RequestMapping("type")
public class TypeController extends BaseController{
	
	@Autowired
	private ITbTypeService typeService;
	
	@GetMapping
	@ApiOperation(value = "分类列表", httpMethod = "GET", notes = "分类列表")
	public AbstractBean newsList(@RequestParam(required = false,defaultValue = "0")Integer depart,@RequestParam(required=false,defaultValue="0") Integer pageNum,@RequestParam(required=false,defaultValue="10") Integer pageSize){
		if (depart == 0) {
			return json(typeService.selectMapsPage(new Page<TbType>(pageNum, pageSize), new EntityWrapper<TbType>().orderBy("sort")));
		}
		else{
		return json(typeService.selectMapsPage(new Page<TbType>(pageNum, pageSize), new EntityWrapper<TbType>().where("depart={0}", depart).orderBy("sort")));
		}
	}
	
	
}